

CC=gcc
C_FLAGS=-O2 -c -ffreestanding -I ../include

ASM=nasm
ASM_FLAGS=-f elf

KERNEL_OBJS=entrance.o kernel.o inout.o util.o video.o kstdio.o memory.o \
            isr.o idt.o gdt.o 

KERNEL_LIB_TARGETS=libmm.a libklib.a
KERNEL_LIBS=-Lmm -lmm -Lklibc -lklibc


kernel.bin: $(KERNEL_OBJS) $(KERNEL_LIB_TARGETS)
	ld -o freeGSD $(KERNEL_OBJS) -Tlink.ld -Map kernel.map $(KERNEL_LIBS)
	mbchk freeGSD
#	gzip -9 -c freeGSD > freeGSZ

.s.o:
	$(ASM) $(ASM_FLAGS) $<

.c.o:
	$(CC) $(C_FLAGS) $<

libmm.a:
	cd mm && make

libklib.a:
	cd klibc && make

clean:
	rm -f *.o
	rm -f *~
	rm -f kernel.map
	rm -f freeGSD
	cd mm && make clean
	cd klibc && make clean
